var app = require('http').createServer()
var io = require('socket.io')(app)
var port = 2000
let sum = 0
app.listen(port)
io.on('connection', function (socket) {
    sum++
    socket.sum
    io.emit('enter', socket.sum + 'come')
    socket.on('message', function (str) {
        io.emit('message', socket.sum + 'say', str)
    })
    socket.on('disconnect', function () {
        io.emit('leave', socket.sum + 'say', 'leave')
    })
})
console.log("websocket server listen port is" + port)
